@extends('app')

@section('content')
<!-- 组卷弹窗 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel" style="color:#2ECC71;">认证图标</h4>
      </div>
      <div class="modal-body" id="modal-body">

      </div>
    </div>
  </div>
</div>
{{-- 表单验证错误信息 --}}
@if ($errors)
    @if ($errors->any())
        <div class="alert alert-danger">
            @foreach($errors->all() as $error)
                <p>{{ $error }}</p>
            @endforeach
        </div>
    @endif
@endif
<ul class="nav nav-tabs">
    <li ><a href="{{ url('/admin/enterprise/examinations')}}">试卷管理</a></li>
    <li class="active"><a href="{{ url('/admin/enterprise/examinations/create') }}">添加</a></li>
</ul>
<form class="form-horizontal" id="examinationForm" method="post">
    <div class="panel panel-default mt20">
        <div class="form-group mt20">
            <label for="" class="col-sm-1 control-label">名称</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" name="name" id="name" placeholder="试卷名称" value="{{ !empty($examination)?$examination->name:'' }}">
            </div>
        </div>

        <div class="form-group">
            <label for="" class="col-sm-1 control-label">最低分</label>
            <div class="col-sm-10">
                <input type="text" name="score_limit" class="form-control" value="{{ !empty($examination)?$examination->score_limit:0 }}" />
                <div class="help-block">最低分，低于最低分则不允许投递简历，为0则为不限制</div>
            </div>
        </div>

        <div class="form-group">
            <label for="" class="col-sm-1 control-label">时间</label>
            <div class="col-sm-10">
                <input type="text" name="times" class="form-control" value="{{ !empty($examination)?$examination->times:0 }}" />
                <div class="help-block">单位：分钟</div>
            </div>
        </div>
        <div class="form-group">
            <label for="" class="col-sm-1 control-label">分值</label>
            <div class="col-sm-10">
                <input type="text" name="score" class="form-control" value="{{ !empty($examination)?$examination->score:0 }}" />
                <div class="help-block">每题的分值，默认为一题 一分</div>
            </div>
        </div>
        @if(!empty($examination))
        <div class="form-group">
            <label for="" class="col-sm-1 control-label">题量</label>
            <div class="col-sm-10">
                <input type="text" name="question_count" class="form-control" value="{{ !empty($examination)?$examination->question_count:0 }}" readonly/>
                <div class="help-block">试卷的题目的数量</div>
            </div>
        </div>
        @endif
        <div class="form-group">
            <label for="" class="col-sm-1 control-label">企业</label>
            <div class="col-sm-10">
                <select class="form-control" name="company_id" onchange="getQuestions(this.value,'/admin/enterprise/examinations/','question')">
                    <option value="0">系统试卷</option>
                    @foreach ($companys as $cpy)
                        <option value="{{ $cpy->id }}" @if(!empty($examination) && $examination->company_id == $cpy->id) selected @endif>{{ $cpy->name }}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="" class="col-sm-1 control-label">组卷</label>
            <div class="col-sm-10 pad-t-10" id="question">
                @foreach ($questions as $qt)
                    <label>
                        <input type="checkbox" name="question_id[]" id="" value="{{ $qt->id }}" @if(!empty($selected) && in_array($qt->id,$selected)) checked @endif>
                        &nbsp;&nbsp;&nbsp;&nbsp;{{ $qt->title }}&nbsp;&nbsp;
                    </label>
                @endforeach
            </div>
        </div>


        <input type="hidden" name="id" value="{{ !empty($examination)?$examination->id:0 }}">
        {!! csrf_field() !!}
    </div>
    <div class="form-inline">
        <button class="btn btn-info" type="button" id="company_save" onclick="saveData('/admin/enterprise/examinations','examinationForm')">
            <i class="icon-ok bigger-110"></i>
            submit
        </button>
        <button type="reset" class="btn">
            <i class="icon-undo bigger-110"></i>
            Reset
        </button>
    </div>
</form>

<script type="text/javascript">
$(function(){
	icheckInput();
});
</script>
@endsection
